﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HelloWorld
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {
            label1.BackColor = Color.BlanchedAlmond;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listView1.Clear();

            for(int i = 0; i < Int32.Parse(textBox1.Text); i++)
            {
                listView1.Items.Add(i.ToString());
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            
        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (IsNumber(e.KeyChar.ToString()))
                e.Handled = false;
            else
                e.Handled = true;
        }

        private bool IsNumber(String s)
        {
            try
            {
                Int32.Parse(s);
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }
}
